﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JobShop
{
    public class TcStatistics
    {
        // Data of the recent generation.
        public Double Average { get; private set; }
        public Double Median { get; private set; }
        public Double StDev { get; private set; }
        public TcSolution BestSolution { get; private set; }
        public TcSolution WorstSolution { get; private set; }
        
        // Data from every last generations.
        public Stack<Double> Bests { get; private set; }
        public Stack<Double> Avgs { get; private set; }
        public Stack<Double> Worsts { get; private set; }
        public Stack<Double> Medians { get; private set; }
        public Stack<Double> StDevs { get; private set; }
        //------------------------------------------------------------------------------

        public TcStatistics(Int32 prmGenSize)
        {
            // Data of the recent generation.
            BestSolution = null;
            WorstSolution = null;
            Average = 0.0f;
            StDev = 0.0f;
            Median = 0.0f;
        
            // Data from every last generations.
            Bests = new Stack<Double>(prmGenSize);
            Worsts = new Stack<Double>(prmGenSize);
            Avgs = new Stack<Double>(prmGenSize);
            StDevs = new Stack<Double>(prmGenSize);
            Medians = new Stack<Double>(prmGenSize);
        }
        //------------------------------------------------------------------------------

        public void Update(TcGeneration prmGeneration)
        {
            BestSolution = prmGeneration.Best.Duplicate();
            WorstSolution = prmGeneration.Worst.Duplicate();
            Average = prmGeneration.Average;
            Median = prmGeneration.Median;
            StDev = prmGeneration.StDev;

            Bests.Push(BestSolution.Fitness);
            Worsts.Push(WorstSolution.Fitness);
            Avgs.Push(Average);
            StDevs.Push(StDev);
            Medians.Push(Median);
        }
        //------------------------------------------------------------------------------

    }
    //------------------------------------------------------------------------------

}
//------------------------------------------------------------------------------